package org.example;

import org.example.entity.Person;
import org.example.entity.User;
import org.example.utils.XStreamUtils;
import org.example.utils.XmlData;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * Hello world!
 * @author haocjia
 */
public class App {

    public static void main(String[] args) throws IOException {

        List<User> list = new ArrayList<>();

        User user = new User();
        user.setName("李三");
        user.setAge(24);
        list.add(user);

        user = new User();
        user.setName("归塞");
        user.setAge(43);
        list.add(user);

        Person person = new Person();

        person.setRace("汉");
        person.setColor("黄");
        person.setCountry("中国");

        person.setList(new XmlData<>("users", list));

        String xml = XStreamUtils.toXml(person);

        Person person1 = (Person) XStreamUtils.toBean(xml,new Person());
        System.out.println(person1);
    }
}
